import React from 'react';
import renderer from 'react-test-renderer';
import { fromJS } from 'immutable';
import { HomePage } from 'pages/home/components/index';

jest.mock('rc-tabs/lib/ScrollableInkTabBar.js', () => (
  props => (
    // eslint-disable-next-line react/prop-types
    <div>{props.children}</div>
  )
));

describe('pages/home/components/index', () => {
  beforeEach(() => {
    HomePage.contextTypes = {
      router: () => null
    };
  });
  
  test('HomePage should render correctly', () => {
    const homeProps = {
      news: fromJS({
        list: [{
          title: 'title',
          desc: 'desc'
        }]
      }),
      stock: fromJS({
        list: [{
          name: 'name',
          code: 'code',
          pinyin: 'pinyin'
        }]
      })
    };
    const systemProps = {
      loading: fromJS({
        display: true,
        text: ''
      })
    };
    const emptyFunction = () => {
    };
    
    const component = renderer.create(
      <HomePage
        home={homeProps}
        system={systemProps}
        getNewsByTitle={emptyFunction}
      />
    );
    const tree = component.toJSON();
    expect(tree).toMatchSnapshot();
  });
});
